var z = 0
var userChoice = prompt("Do you choose rock, paper or scissors?")
var x = 0
if (userChoice === "rock")
{x = 1}
if (userChoice === "paper")
{x = 1}
if (userChoice === "scissors")
{x = 1}
while (x !== 1)
{
    var userChoice = prompt("Do you choose rock, paper or scissors?");
var x = 0
if (userChoice === "rock")
{x = 1}
if (userChoice === "paper")
{x = 1}
if (userChoice === "scissors")
{x = 1}
}
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice)





var compare = function (choice1, choice2) {
    
    if (choice1 === choice2)
    {
        console.log ("The result is a tie! Play Again!")
     z = 1
        
    }
    else if (choice1 === "rock" ){
        if (choice2 === "scissors")
        {console.log ("rock wins")}
        else
        {console.log ("paper wins")}
    }
    else if (choice1 === "paper") {
        if (choice2 === "rock")
        {
            console.log ("paper wins")
        }
        else {
            console.log ( "scissors wins")
        }
    }
    else if ( choice1 === "scissors"){
        if (choice2 === "rock")
        {
           console.log ("rock wins")
        }   
        else {
         console.log ("scissors wins")
        }
    }
}


compare (userChoice, computerChoice)









if (z === 1)
{y = 1
z = 0
}
else
{var playAgain = prompt ("Do you want to play again?")
if (playAgain === "yes")
{y = 1}
else 
{console.log ("Game Over!")}
}
while (y === 1)
{
 var userChoice = prompt("Do you choose rock, paper or scissors?")
var x = 0
if (userChoice === "rock")
{x = 1}
if (userChoice === "paper")
{x = 1}
if (userChoice === "scissors")
{x = 1}
while (x !== 1)
{
    var userChoice = prompt("Do you choose rock, paper or scissors?");
var x = 0
if (userChoice === "rock")
{x = 1}
if (userChoice === "paper")
{x = 1}
if (userChoice === "scissors")
{x = 1}
}
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
compare (userChoice, computerChoice)
 var playAgain = prompt ("Do you want to play again?")
if (playAgain === "yes")
{y = 1}
else 
{console.log ("Game Over!")
y = 0
}

}
